package guda.house.biz.form.bill;

import guda.house.dal.dataobject.BillWaterDO;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/15.
 */
public class BillWaterEditForm extends BillWaterForm{

    @NotNull(message = "不能为空")
    private Long billId;

    public Long getBillId() {
        return billId;
    }

    public void setBillId(Long billId) {
        this.billId = billId;
    }

    public BillWaterDO toDO(){
        BillWaterDO billWaterDO = super.toDO();
        billWaterDO.setBillId(billId);
        return billWaterDO;
    }

    public void initForm(BillWaterDO billWaterDO){
        setBillId(billWaterDO.getBillId());
        setRecordCurrent(billWaterDO.getRecordCurrent());
        setIsPayed(billWaterDO.getIsPayed());
        setRecordLast(billWaterDO.getRecordLast());
        setRecordCurrent(billWaterDO.getRecordCurrent());
        setRecordYear(billWaterDO.getRecordYear());
        setRecordMonth(billWaterDO.getRecordMonth());
        if(billWaterDO.getGmtEnd()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtEnd(simpleDateFormat.format(billWaterDO.getGmtEnd()));
        }
        if(billWaterDO.getGmtStart()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtStart(simpleDateFormat.format(billWaterDO.getGmtStart()));
        }
        if(billWaterDO.getGmtRecord()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtRecord(simpleDateFormat.format(billWaterDO.getGmtRecord()));
        }
    }
}
